//package com.superb.gateway.filter;
//
//import cn.dev33.satoken.same.SaSameUtil;
//import cn.dev33.satoken.stp.StpUtil;
//import com.superb.common.core.constants.SaToken;
//import com.superb.common.utils.HeardersUtils;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.cloud.gateway.filter.GatewayFilterChain;
//import org.springframework.cloud.gateway.filter.GlobalFilter;
//import org.springframework.core.Ordered;
//import org.springframework.http.server.reactive.ServerHttpRequest;
//import org.springframework.stereotype.Component;
//import org.springframework.web.server.ServerWebExchange;
//import reactor.core.publisher.Mono;
//
//import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR;
//
///**
// * 全局拦截器，作用所有的微服务
// * 1. 添加请求头中参数TOKEN转发鉴权
// * 2. 重写StripPrefix = 1,支持全局
// * @Author: ajie
// * @CreateTime: 2024-06-19 13:12
// */
//@Slf4j
//@Component
//public class RequestGlobalFilter implements GlobalFilter, Ordered {
//
//
//    @Override
//    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
//        // 1.添加转发请求头sa-token标记，下游服务鉴权处理
//        ServerHttpRequest newRequest = exchange
//                .getRequest()
//                .mutate()
//                // 为请求追加 Same-Token 参数
//                .header(SaSameUtil.SAME_TOKEN, SaSameUtil.getToken())
//                .build();
//        ServerWebExchange newExchange = exchange.mutate().request(newRequest).build();
//        return chain.filter(newExchange);
//    }
//
//    @Override
//    public int getOrder() {
//        return 10;
//    }
//}
